package com.exam.controller;

import com.exam.service.AutoGradingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

//自动评分
@RestController
@RequestMapping("/api/auto-grading")
public class AutoGradingController {

    @Autowired
    private AutoGradingService autoGradingService;

    @PostMapping
    public Map<String, Object> gradeObjectiveQuestions(@RequestBody Map<String, String> userAnswers) {
        return autoGradingService.gradeObjectiveQuestions(userAnswers);
    }
    //方法签名，接收一个Map<String, String>类型的参数userAnswers，并返回一个Map<String, Object>类型的结果。
    //@RequestBody：表示userAnswers参数应该从HTTP请求的请求体中获取，
    // 并且请求体的内容应该被解析为一个Map<String, String>对象。
    //调用AutoGradingService的gradeObjectiveQuestions方法，并传入userAnswers参数，返回评分结果。
}